package webBeans;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;



import beansInterfaces.BasicProductMgr;
import beansInterfaces.UserMgr;
import dto.ResidenceDTO;




@ManagedBean(name="residence")
@RequestScoped
public class ResidenceCreationBean 
{
	@EJB
	private BasicProductMgr basicProductMgr;
	@EJB
	private UserMgr u;
	
	private ResidenceDTO currentResidence;
	

	
	
	
	public ResidenceCreationBean() {}
	

	public void createResidence() 
	{	
		this.currentResidence.setAdmin(u.getUserDTO().getUsername());
		this.basicProductMgr.addResidence(currentResidence);
		this.currentResidence = new ResidenceDTO();
	}

	public ResidenceDTO getCurrentResidence() {
		return currentResidence;
	}

	public void setCurrentResidence(ResidenceDTO currentResidence) {
		this.currentResidence = currentResidence;
	}
	
	



	@PostConstruct
	public void initializeCurrent()
	{
		this.currentResidence = new ResidenceDTO();
	}
	

	


	
	
}
